package com.itmiaojie.controller;

import com.itmiaojie.pojo.ResponseResult;
import com.itmiaojie.service.UploadService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RestController
@RequestMapping("/upload")
public class CommonController {
    @Autowired
    private UploadService uploadService;

    @PostMapping
    public ResponseResult upload(MultipartFile img){
        try {
           return uploadService.uploadImg(img);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }
}
